import Vue from 'vue'
import Vuex from 'vuex'
import Router from '@/router'

Vue.use(Vuex)
const store = new Vuex.Store({
	//	strict: true,
	state: {
		// user: {},
		count: 10,
		userListIndex:[],
		orderListAllIndex:0,  //
		orderListIndex:0,     //
		CreditListIndex:0 ,    //	
		userListIndex1:0,
		orderListAllIndex1:0,  //
		orderListIndex1:0,     //
		CreditListIndex1:0 ,    //
		orderListAllIndex2:0,  //
		orderListIndex2:0,     //
		CreditListIndex2:0 ,    //
		userListIndex2:0,
		userListIndex3:0,
		userListIndex4:0,
		userListIndex5:0,
	},
	getters: {
		getCount: state => state.count,
		getUserListIndex: state => state.userListIndex,  
		getOrderListIndex: state => state.orderListIndex, //分类类型
		getOrderListAllIndex: state => state.orderListAllIndex, //分类地区
		getCreditListIndex: state => state.CreditListIndex,  //;
		getUserListIndex1: state => state.userListIndex1,  /////电影列表
		getOrderListIndex1: state => state.orderListIndex1, //
		getOrderListAllIndex1: state => state.orderListAllIndex1, //
		getCreditListIndex1: state => state.CreditListIndex1,  //;
		getOrderListIndex2: state => state.orderListIndex2, //
		getOrderListAllIndex2: state => state.orderListAllIndex2, //
		getCreditListIndex2: state => state.CreditListIndex2,  //;
		getUserListIndex2: state => state.userListIndex2,  //;
		getUserListIndex3: state => state.userListIndex3,  //;
		getUserListIndex4: state => state.userListIndex4,  //;
		getUserListIndex5: state => state.userListIndex5,  //;
	},
	mutations: {
		INCREMENT(state) {
			state.count++
		  },
		  DECREMENT(state) {
			state.count--
		  },
		  GETUSERLISTINDEX(state,pageIndex){
			let routelist = state.userListIndex;
			routelist.push(pageIndex);
			for (var i = 0; i < routelist.length; i++) {
				for (var j =i+1; j <routelist.length; ) {
					if (routelist[i].path == routelist[j].path ) {//通过photoid属性进行匹配；
						routelist.splice(j, 1);//去除重复的对象；
					}else {
						j++;
					}
				}
			}	
				state.userListIndex = routelist;
		  },
		  SETORDERLISTINDEX(state,pageIndex){
			state.orderListIndex = pageIndex;
		  },
		  SETORDERLISTALLINDEX(state,pageIndex){
			state.orderListAllIndex = pageIndex;
		  },
		  SETCREDITLISTINDEX(state,pageIndex){
			state.CreditListIndex = pageIndex;
		  },
		  GETUSERLISTINDEX1(state,pageIndex){
			state.userListIndex1 = pageIndex;
		  },
		  SETORDERLISTINDEX1(state,pageIndex){
			state.orderListIndex1 = pageIndex;
		  },
		  SETORDERLISTALLINDEX1(state,pageIndex){
			state.orderListAllIndex1 = pageIndex;
		  },
		  SETCREDITLISTINDEX1(state,pageIndex){
			state.CreditListIndex1 = pageIndex;
		  },
		  SETORDERLISTINDEX2(state,pageIndex){
			state.orderListIndex2 = pageIndex;
		  },
		  SETORDERLISTALLINDEX2(state,pageIndex){
			state.orderListAllIndex2 = pageIndex;
		  },
		  SETCREDITLISTINDEX2(state,pageIndex){
			state.CreditListIndex2 = pageIndex;
		  },
		  GETUSERLISTINDEX2(state,pageIndex){
			state.userListIndex2 = pageIndex;
		  },
		  GETUSERLISTINDEX3(state,pageIndex){
			state.userListIndex3 = pageIndex;
		  },
  		  GETUSERLISTINDEX4(state,pageIndex){
			state.userListIndex4 = pageIndex;
		  },
		  GETUSERLISTINDEX5(state,pageIndex){
			state.userListIndex5 = pageIndex;
		  },
	},
	actions: {
		increment({commit}){
			commit('INCREMENT')
		},
		decrement({commit}){
			commit('DECREMENT')
		},
		getUserListIndex({commit},pageIndex){
			commit('GETUSERLISTINDEX',pageIndex)
		},
		setOrderListIndex({commit},pageIndex){
			commit('SETORDERLISTINDEX',pageIndex)
		},
		setOrderListAllIndex({commit},pageIndex){
			commit('SETORDERLISTALLINDEX',pageIndex)
		},
		setCreditListIndex({commit},pageIndex){ 
			commit('SETCREDITLISTINDEX',pageIndex)
		},
		getUserListIndex1({commit},pageIndex){
			commit('GETUSERLISTINDEX1',pageIndex)
		},
		setOrderListIndex1({commit},pageIndex){
			commit('SETORDERLISTINDEX1',pageIndex)
		},
		setOrderListAllIndex1({commit},pageIndex){
			commit('SETORDERLISTALLINDEX1',pageIndex)
		},
		setCreditListIndex1({commit},pageIndex){ 
			commit('SETCREDITLISTINDEX1',pageIndex)
		},
		setOrderListIndex2({commit},pageIndex){
			commit('SETORDERLISTINDEX2',pageIndex)
		},
		setOrderListAllIndex2({commit},pageIndex){
			commit('SETORDERLISTALLINDEX2',pageIndex)
		},
		setCreditListIndex2({commit},pageIndex){ 
			commit('SETCREDITLISTINDEX2',pageIndex)
		},
		getUserListIndex2({commit},pageIndex){
			commit('GETUSERLISTINDEX2',pageIndex)
		},
		getUserListIndex3({commit},pageIndex){
			commit('GETUSERLISTINDEX3',pageIndex)
		},
		getUserListIndex4({commit},pageIndex){
			commit('GETUSERLISTINDEX4',pageIndex)
		},
		getUserListIndex5({commit},pageIndex){
			commit('GETUSERLISTINDEX5',pageIndex)
		},
	}
})

export default store
